<?php

namespace App\Http\Controllers\Api\User;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Facades\Services\User\WeightService;
use App\Facades\Utils\ValidateParameter;

class WeightController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create(Request $request)
    {
        $rules = [
            'weight' => 'required'
        ];

        ValidateParameter::validate($request,$rules);

        $data = $request->all();

        WeightService::createRecord($data);

        return formatJsonResponse();
    }

    public function update(Request $request){
        $rules = [
            'id' => 'required|exists:weights,id',
            'weight' => 'required'
        ];

        ValidateParameter::validate($request,$rules);

        $data = $request->all();

        WeightService::updateTodayRecord($data);

        return formatJsonResponse();
    }
}
